﻿using Corina.Datamodel.Base;
using Corina.Datamodel.Interface;
using Corina.Enumerations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Serialization;

namespace Corina.Datamodel.Entities
{
    [XmlTypeAttribute(Namespace = "http://tempuri.org/")]
    [DataContract]
    public class DeviceSaleInfo : DatamodelEntity, IDeviceSale
    {
        #region Fields
        private int _id;
        private string _deviceSn;
        private DateTime _saleDate = DateTime.Now;
        private double _price = 0;
        private string _salesperson = string.Empty;
        private int _userId = 0;
        #endregion

        #region Properties
        [DataMember]
        public int Id
        {
            get { return _id; }
            set
            {
                _id = value;
                RaisePropertyChanged(() => Id);
            }
        }

        [DataMember]
        public string DeviceSn
        {
            get { return _deviceSn; }
            set
            {
                _deviceSn = value;
                RaisePropertyChanged(() => DeviceSn);
            }
        }

        [DataMember]
        public DateTime SaleDate
        {
            get { return _saleDate; }
            set
            {
                _saleDate = value;
                RaisePropertyChanged(() => SaleDate);
            }
        }

        [DataMember]
        public double Price
        {
            get { return _price; }
            set
            {
                _price = value;
                RaisePropertyChanged(() => Price);
            }
        }

        [DataMember]
        public string Salesperson
        {
            get { return _salesperson; }
            set
            {
                _salesperson = value;
                RaisePropertyChanged(() => Salesperson);
            }
        }

        [DataMember]
        public int UserId
        {
            get { return _userId; }
            set
            {
                _userId = value;
                RaisePropertyChanged(() => UserId);
            }
        }
        #endregion

        protected override IEnumerable<DatabaseColumn> InitColumns()
        {
            yield return new DatabaseColumn("Id", true);
            yield return new DatabaseColumn("DeviceSn");
            yield return new DatabaseColumn("SaleDate");
            yield return new DatabaseColumn("Price");
            yield return new DatabaseColumn("Salesperson");
            yield return new DatabaseColumn("UserId");
        }
    }
}